﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TestLocalizableViewModel.ViewModels;
using System.Globalization;
using System.Threading;
using InnovTech.Util;
using TestLocalizableViewModel.Views;
using InnovTech.Wpf;
using InnovTech.Localization;

namespace TestLocalizableViewModel
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region configure View

            LocalizableView _view = new LocalizableView();
            ViewModelLocalizableView vm = new ViewModelLocalizableView();
            _view.DataContext = vm;
            _view.RegisterWeakAction(() => 
            {
                vm.FirstLocalizableItem = Properties.Resources.FirstLocalizableItem;
                vm.SecondLocalizableItem = Properties.Resources.SecondLocalizableItem;
            });
            _container.Content = _view;

            #endregion View

            #region configure Language manager
            LanguageManager.Default.LanguageChanged += (sender, args) =>
            {
                WpfWeakActionExt.ExecuteActions();
            };
            LanguageManager.Default.RegisterLanguage(new CultureInfo("en-US"), new CultureInfo("de-DE"));

            #endregion configure Language manager




            _languageSelector.ItemsSource = LanguageManager.Default.AvaliableLanguages;
            _languageSelector.SelectionChanged += (sender, args) =>
            {
                LanguageManager.Default.CurrentLanguage = _languageSelector.SelectedItem as CultureInfo;
            };

            _bntDelete.Click += (sender, args) =>
            {
                _container.Content = _container.Content != null ? null : _view;
            };

        }

    }
}
